﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_ListFeedbacks : System.Web.UI.Page
{
    ShopDataContext db = new ShopDataContext();

    protected void Page_Load(object sender, EventArgs e)
    {
        pnl.Visible = false;
    }

    protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        if(e.CommandName == "Select")
        {
            pnl.Visible = true;

            Label lbl = e.Item.Controls[0].FindControl("fIdLabel") as Label;

            Feedback feedback = (from fb in db.Feedbacks
                               where fb.fId == int.Parse(lbl.Text)
                               select fb).FirstOrDefault();

            feedback.fActive = true;
            db.SubmitChanges();

            var query = from fb in db.Feedbacks
                        where fb.fId == int.Parse(lbl.Text)
                        select new { Id = fb.fId, FullName = fb.fFullName,
                                    Email = fb.fEmail, Title = fb.fTitle,
                                    Message = fb.fMessage, Viewed = fb.fActive };
            DetailsView1.DataSource = query;
            DetailsView1.DataBind();
        }
    }
}